package com.gewe.wxChat.manager;

import com.gewe.wxChat.manager.strategy.DefaultJudgeStrategy;
import com.gewe.wxChat.manager.strategy.SanZhiStrategy;
import com.gewe.wxChat.manager.strategy.JudgeStrategy;
import com.gewe.wxChat.model.dto.gewe.TextCallback;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.HashMap;

//工厂，用于生成各个
@Service
public class JudgeManager {
    
    
    private final static String[] SanZhiManage_KeyWord ={"代收协议","宝奇","签宝","合同","两个链接","e签","E签","邀约","短信","运输合同","【支付问题】"};

    @Resource
    private DefaultJudgeStrategy defaultJudgeStrategy;

    @Resource
    private SanZhiStrategy sanZhiStrategy;
    public void doJudge(TextCallback textCallback){
        JudgeStrategy judgeStrategy=defaultJudgeStrategy;
        String content=textCallback.getContent();
        if(StringUtils.isNotBlank(content) && sanZhijudge(content)){
            judgeStrategy=sanZhiStrategy;
        }
        
        judgeStrategy.analysis(textCallback);
    }
    
    private boolean sanZhijudge(String content){
        
        for (String keyWord:SanZhiManage_KeyWord){
            if(content.contains(keyWord)){
                return true;
            }
        }
        return false;
    }
}
